<!--
  ~ /*
  ~  *    Copyright 2020-2021 luter.me
  ~  *
  ~  *    Licensed under the Apache License, Version 2.0 (the "License");
  ~  *    you may not use this file except in compliance with the License.
  ~  *    You may obtain a copy of the License at
  ~  *
  ~  *      http://www.apache.org/licenses/LICENSE-2.0
  ~  *
  ~  *    Unless required by applicable law or agreed to in writing, software
  ~  *    distributed under the License is distributed on an "AS IS" BASIS,
  ~  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~  *    See the License for the specific language governing permissions and
  ~  *    limitations under the License.
  ~  */
  -->

<!DOCTYPE html>
<html lang="zh-CN" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      layout:decorate="~{pages/tpl/layout.html}" xmlns:auth="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>thymeleaf 权限标签</title>
    <style>
        .card {
            margin-top: 10px !important;
        }
    </style>
</head>
<body>
<section layout:fragment="content">
    <div class="container">
        <div class="row">
            <div class="col">
                <h1>Thymeleaf 权限 tags</h1>
            </div>
        </div>
        <div class="row">
            <div class="col-6">
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">属性 :[auth:user property="fieldName"]</h5>
                        <small class="text-secondary fw-light fst-italic">从当前登录用户的 UserDetails 对象中获取信息,
                            property 为空返回 principal</small>
                        <div class="card-text text-primary">
                            <p>appId: <span auth:user property="appId"></span></p>
                            <p>userId: <span auth:user property="userId"></span></p>
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">属性 :[auth:token property="fieldName"]</h5>
                        <small class="text-secondary fw-light fst-italic">从当前登录用户的 token 对象中获取信息,
                            property 为空返回 id</small>
                        <div class="card-text text-primary">
                            <p>token.Id: <span auth:token property="id"></span></p>
                            <p>token.Iat: <span auth:token property="iat"></span></p>
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">属性 :[auth:authenticated]</h5>
                        <small class="text-secondary fw-light fst-italic">已经登录，登录后才能看见下面的字</small>
                        <div auth:authenticated class="card-text text-primary">
                            <h4>看见没?</h4>
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">属性 :[auth:notAuthenticated]</h5>
                        <small class="text-secondary fw-light fst-italic">未登录，未登录才能看见下面的字</small>
                        <div auth:notAuthenticated class="card-text text-primary">
                            <h4>登录后这个字你看不见?</h4>
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">属性 :[auth:hasAnyPerms="perm1,perm2,permN"]</h5>
                        <small class="text-secondary fw-light fst-italic">具备多个权限其中之一</small>
                        <p>perms:[catDelete,catUpdate]</p>
                        <div auth:hasAnyPerms="catDelete,catUpdate" class="card-text text-primary">
                            <h4> [catDelete,catUpdate] 有其一</h4>
                        </div>
                        <hr>
                        <p>perms:[catList,catUpdate]</p>
                        <div auth:hasAnyPerms="catList,catUpdate" class="card-text text-primary">
                            <h4>[catList,catUpdate] 有其一</h4>
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">属性 :[auth:hasPerms="perm1,perm2,permN"]</h5>
                        <small class="text-secondary fw-light fst-italic">全部具备多个权限</small>
                        <p>perms:[catDelete,catUpdate]</p>
                        <div auth:hasPerms="catDelete,catUpdate" class="card-text text-primary">
                            <h4> [catDelete,catUpdate] 全部</h4>
                        </div>
                        <hr>
                        <p>perms:[catList,catSave]</p>
                        <div auth:hasPerms="catList,catSave" class="card-text text-primary">
                            <h4>[catList,catSave] 全部</h4>
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">属性 :[auth:hasAnyRoles="role1,role2,roleN"]</h5>
                        <small class="text-secondary fw-light fst-italic">具备多个角色其中之一</small>
                        <p>roles:[catDelete,catUpdate]</p>
                        <div auth:hasAnyRoles="catDelete,catUpdate" class="card-text text-primary">
                            <h4> [catDelete,catUpdate] 有其一</h4>
                        </div>
                        <hr>
                        <p>roles:[catList,catUpdate]</p>
                        <div auth:hasAnyRoles="catList,catUpdate" class="card-text text-primary">
                            <h4>[catList,catUpdate] 有其一</h4>
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">属性 :[auth:hasRoles="role1,role2,roleN"]</h5>
                        <small class="text-secondary fw-light fst-italic">全部具备多个角色</small>
                        <p>roles:[catDelete,catUpdate]</p>
                        <div auth:hasRoles="catDelete,catUpdate" class="card-text text-primary">
                            <h4> [catDelete,catUpdate] 全部</h4>
                        </div>
                        <hr>
                        <p>roles:[catList,catSave]</p>
                        <div auth:hasRoles="catList,catSave" class="card-text text-primary">
                            <h4>[catList,catSave] 全部</h4>
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">属性 :[auth:lacksPerms="perm1,perm2,permN"]</h5>
                        <small class="text-secondary fw-light fst-italic">缺少权限，多个权限里，至少要具备一个</small>
                        <p>perms:[catDelete,catUpdate]</p>
                        <div auth:lacksPerms="catDelete,catUpdate" class="card-text text-primary">
                            <h4> [catDelete,catUpdate] 一个也不具备</h4>
                        </div>
                        <hr>
                        <p>perms:[catList,catUpdate]</p>
                        <div auth:lacksPerms="catList,catUpdate" class="card-text text-primary">
                            <h4>[catList,catUpdate] 一个也不具备</h4>
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">属性 :[auth:lacksRoles="role1,role2,roleN"]</h5>
                        <small class="text-secondary fw-light fst-italic">多个角色里，至少要具备一个</small>
                        <p>roles:[catDelete,catUpdate]</p>
                        <div auth:lacksRoles="catDelete,catUpdate" class="card-text text-primary">
                            <h4> [catDelete,catUpdate] 一个也不具备</h4>
                        </div>
                        <hr>
                        <p>roles:[catList,catSave]</p>
                        <div auth:lacksRoles="catList,catSave" class="card-text text-primary">
                            <h4>[catList,catSave] 一个也不具备</h4>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-6">
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">标签 :[&lt;auth:user property=&quot;fieldName&quot;/&gt;]</h5>
                        <small class="text-secondary fw-light fst-italic">从当前登录用户的 UserDetails 对象中获取信息,
                            property 为空返回 principal</small>
                        <div class="card-text text-primary">
                            <p>appId:
                                <auth:user property="appId"/>
                            </p>
                            <p>userId:
                                <auth:user property="userId"/>
                            </p>
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">标签 :[&lt;auth:token property=&quot;fieldName&quot;/&gt;]</h5>
                        <small class="text-secondary fw-light fst-italic">从当前登录用户的 token 对象中获取信息,
                            property 为空返回 id</small>
                        <div class="card-text text-primary">
                            <p>token.Id:
                                <auth:token property="id"/>
                            </p>
                            <p>token.Iat:
                                <auth:token property="iat"/>
                            </p>
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title fs-6">标签 :[&lt;auth:authenticated&gt;text&lt;/auth:authenticated&gt;]</h5>
                        <small class="text-secondary fw-light fst-italic">已经登录，登录后才能看见下面的字</small>
                        <auth:authenticated>
                            <h4 class="card-text text-primary">看见没?</h4>
                        </auth:authenticated>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title fs-6">标签 :[&lt;auth:notAuthenticated&gt;text&lt;/auth:notAuthenticated&gt;
                            ]</h5>
                        <small class="text-secondary fw-light fst-italic">未登录，未登录才能看见下面的字</small>
                        <auth:notAuthenticated>
                            <h4 class="card-text text-primary">登录后这个字你看不见?</h4>
                        </auth:notAuthenticated>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title fs-6">标签 :[&lt;auth:hasAnyPerms name=&quot;perm1,perm2...permN&quot; &gt;text&lt;/auth:hasAnyPerms&gt;]</h5>
                        <small class="text-secondary fw-light fst-italic">具备多个权限其中之一</small>
                        <p>perms:[catDelete,catUpdate]</p>
                        <auth:hasAnyPerms name="catDelete,catUpdate">
                            <h4 class="card-text text-primary"> [catDelete,catUpdate] 有其一</h4>
                        </auth:hasAnyPerms>
                        <hr>
                        <p>perms:[catList,catUpdate]</p>
                        <auth:hasAnyPerms name="catList,catUpdate">
                            <h4 class="card-text text-primary">[catList,catUpdate] 有其一</h4>
                        </auth:hasAnyPerms>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title fs-6">标签 :[&lt;auth:hasPerms name=&quot;perm1,perm2...permN&quot; &gt;text&lt;/auth:hasPerms&gt;]</h5>
                        <small class="text-secondary fw-light fst-italic">全部具备多个权限</small>
                        <p>perms:[catDelete,catUpdate]</p>

                        <auth:hasPerms name="catDelete,catUpdate">
                            <h4 class="card-text text-primary"> [catDelete,catUpdate] 全部</h4>
                        </auth:hasPerms>
                        <hr>
                        <p>perms:[catList,catSave]</p>
                        <auth:hasPerms name="catList,catSave">
                            <h4 class="card-text text-primary">[catList,catSave] 全部</h4>
                        </auth:hasPerms>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title fs-6">标签 :[&lt;auth:hasAnyRoles name=&quot;role1,role2...roleN&quot; &gt;text&lt;/auth:hasAnyRoles&gt;]</h5>
                        <small class="text-secondary fw-light fst-italic">具备多个角色其中之一</small>
                        <p>roles:[catDelete,catUpdate]</p>
                        <auth:hasAnyRoles name="catDelete,catUpdate">
                            <h4 class="card-text text-primary"> [catDelete,catUpdate] 有其一</h4>
                        </auth:hasAnyRoles>
                        <hr>
                        <p>roles:[catList,catUpdate]</p>
                        <auth:hasAnyRoles name="catList,catUpdate">
                            <h4 class="card-text text-primary">[catList,catUpdate] 有其一</h4>
                        </auth:hasAnyRoles>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title fs-6">标签 :[&lt;auth:hasRoles name=&quot;role1,role2...roleN&quot; &gt;text&lt;/auth:hasRoles&gt;]</h5>
                        <small class="text-secondary fw-light fst-italic">全部具备多个角色</small>
                        <p>roles:[catDelete,catUpdate]</p>
                        <auth:hasRoles name="catDelete,catUpdate">
                            <h4 class="card-text text-primary"> [catDelete,catUpdate] 全部</h4>
                        </auth:hasRoles>
                        <hr>
                        <p>roles:[catList,catSave]</p>
                        <auth:hasRoles name="catList,catSave">
                            <h4 class="card-text text-primary">[catList,catSave] 全部</h4>
                        </auth:hasRoles>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title fs-6">标签 :[&lt;auth:lacksPerms name=&quot;perm1,perm2...permN&quot; &gt;text&lt;/auth:lacksPerms&gt;]</h5>
                        <small class="text-secondary fw-light fst-italic">缺少权限，多个权限里，至少要具备一个</small>
                        <p>perms:[catDelete,catUpdate]</p>
                        <auth:lacksPerms name="catDelete,catUpdate">
                            <h4 class="card-text text-primary"> [catDelete,catUpdate] 一个也不具备</h4>
                        </auth:lacksPerms>
                        <hr>
                        <p>perms:[catList,catUpdate]</p>
                        <auth:lacksPerms name="catList,catUpdate">
                            <h4 class="card-text text-primary">[catList,catUpdate] 一个也不具备</h4>
                        </auth:lacksPerms>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title fs-6">标签 :[&lt;auth:lacksRoles name=&quot;role1,role2...roleN&quot; &gt;text&lt;/auth:lacksRoles&gt;]</h5>
                        <small class="text-secondary fw-light fst-italic">多个角色里，至少要具备一个</small>
                        <p>roles:[catDelete,catUpdate]</p>
                        <auth:lacksRoles name="catDelete,catUpdate">
                            <h4 class="card-text text-primary"> [catDelete,catUpdate] 一个也不具备</h4>
                        </auth:lacksRoles>
                        <hr>
                        <p>roles:[catList,catSave]</p>
                        <auth:lacksRoles name="catList,catSave">
                            <h4 class="card-text text-primary">[catList,catSave] 一个也不具备</h4>
                        </auth:lacksRoles>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>


</body>
</html>